package gui;

import communications.*;
import gui.Main.*;
import java.io.ObjectStreamException;
import java.io.Serializable;

public class NetworkPrinter implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -827401015270908826L;

	private LocalObjectId localId;
	
	private static NetworkPrinter singleton;
	
	public static NetworkPrinter getSingleton()
	{
		if (singleton == null)
		{
			singleton = new NetworkPrinter();
			ObjectDB.getSingleton().store(singleton.getLocalObjectId(), singleton);
		}
		
		return singleton;
	}
	
	protected NetworkPrinter()
	{
		localId = new LocalObjectId();
	}
	
	public void print(Object message)
	{
		GUI.getSingleton(null).printToTracePanel(message);
	}

	public LocalObjectId getLocalObjectId() {
		return localId;
	}
	
	public Object writeReplace() throws ObjectStreamException
	{
		return new GUIObserverProxy(new GlobalObjectId(localId));
	}
}
